﻿using System;
using System.Drawing;
using Loki.Commands;
using Loki.UI;
using Loki.UI.Win;

namespace Luna.UI.Win
{
    /// <summary>
    /// Main view.
    /// </summary>
    public partial class MainView : MDIContainerViewBase, IView<MainViewModel>
    {
        public MainView()
        {
            InitializeComponent();
            Icon = Icon.FromHandle(Properties.Resources.ApplicationIconSmall.GetHicon());
            BindingChanged += MainView_BindingChanged;
        }

        #region Bindings
        private void MainView_BindingChanged(object P_Sender, EventArgs e)
        {
            DataBinder.OneWay(BAR_CurrentUser, b => b.Caption, ViewModel, v => v.CurrentUser);
            DataBinder.SetCommand(BTN_Save, b => b.Enabled, ApplicationCommands.SAVE);
        }

        public new MainViewModel ViewModel
        {
            get { return (MainViewModel)base.ViewModel; }
            set { base.ViewModel = value; }
        }
        #endregion

        #region Menu commands

        private void NAI_Accounts_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            LunaCommands.Navigation.Account.ADMIN.Execute(null);
        }

        private void NAI_Reporting_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            LunaCommands.Navigation.Account.REPORTING.Execute(null);
        }

        private void NAI_Account_Categories_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            LunaCommands.Navigation.Account.CATEGORIES.Execute(null);
        }

        private void NAI_Users_Admin_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            LunaCommands.Navigation.User.ADMIN.Execute(null);
        }

        private void NAI_Projects_List_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            LunaCommands.Navigation.Project.LIST.Execute(null);
        }

        private void NAI_Projects_Reporting_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            LunaCommands.Navigation.Project.REPORTING.Execute(null);
        }

        private void NAI_Contacts_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
        }

        private void NAI_Companies_LinkClicked(object P_Sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
        }

        #endregion

        private void BTN_Save_ItemClick(object P_Sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ApplicationCommands.SAVE.Execute(null);
        }
    }
}
